#!/bin/bash 

#LCNT-START 
touch .lcnt
lcnt=`cat .lcnt`

let lcnt=$lcnt+1
echo $lcnt > .lcnt
#LCNT-END

#TIME-START 
#timedatectl set-timezone Asia/Shanghai && timedatectl set-ntp true
xtime=`date '+%Y/%m/%d-%H:%M:%S'`
#TIME-END

#AWK-START 
#Debian - buster
#cat ./script/version.x | awk '{gsub(/\@ver\@|\@version\@/,'$lcnt')};1' 2>&1 | tee src/version.h
#cat ./script/commit.x | awk -v time=$(date '+%Y/%m/%d-%H:%M:%S') '{gsub(/\@date\@/,'time');gsub(/\@ver\@|\@version\@/,'$lcnt')};1' 2>&1 | tee commit

#Debian - bookworm
cat ./script/version.x | awk '{gsub(/@ver@|@version@/,'$lcnt')};1' 2>&1 | tee src/version.h
cat ./script/commit.x | awk -v time=$(date '+%Y/%m/%d-%H:%M:%S') '{gsub(/@date@/,'time');gsub(/@ver@|@version@/,'$lcnt')};1' 2>&1 | tee commit
#AWK-END
